﻿@{
    Layout = null;
}

@using LY.Manage.Model

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>为用户分配角色</title>
    <script src="~/Scripts/jquery-1.8.2.min.js"></script>
    <script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>

    <script type="text/javascript">
        function subForm()
        {
            //console.log("ShowSetUserRoleInfo->提交数据")
            $("#form1").submit();
        }

        function afterSet(data)
        {
            //console.log("ShowSetUserRoleInfo->afterSet"+data)
            window.parent.setUserRoleAfter(data);
        }


    </script>
</head>
<body>
    <div>
        为用户 @{
            UserInfo userInfo = ViewBag.UserInfo;
            @userInfo.UName
        }分配角色

        <br />
        @using (Ajax.BeginForm("SetUserRole","UserInfo",new {},new AjaxOptions(){
            HttpMethod="post" ,OnSuccess="afterSet"
        }, new { id = "form1" }))
        {
            <input type="hidden" name="userId" value="@userInfo.ID" />
            List<RoleInfo> roleInfoList = ViewBag.AllRoleInfo;
            List<int> roleInfoIdList = ViewBag.AllExistRoleId;
            
            foreach(RoleInfo roleInfo in roleInfoList)
            {
                var checkName="ckb_roleinfo_"+roleInfo.ID;
                if(roleInfoIdList.Contains(roleInfo.ID))
                {
                    <input type="checkbox" name="@checkName" value="@roleInfo.ID" checked="checked" />@roleInfo.RoleName
                }
                else
                {
                    <input type="checkbox" name="@checkName" value="@roleInfo.ID" />@roleInfo.RoleName
                }
                    
            }
            
        }
       

        
    </div>
</body>
</html>
